package com.king.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @ClassName: Handler
 * @Description:  Handler方法相关信息
 * @Author: wangchangyong
 * @Date: 2020/4/12 15:51
 * @Version: 1.0.0
 **/
public class Handler {

    /**
     * 方法的对象 method.invoke(obj, ...)
     */
    private Object controller;

    /**
     * 具体方法
     */
    private Method method;

    /**
     * URL
     */
    private Pattern pattern;

    /**
     * 参数顺序
     * 执行方法时进行参数绑定
     * key:参数名
     * value:第几个参数
     */
    private Map<String, Integer> paramIndexMapping;

    /**
     * 安全用户
     */
    private String[] securityUser;

    public Handler(Object controller, Method method, Pattern pattern, String[] securityUser) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.securityUser = securityUser;
        this.paramIndexMapping = new HashMap<>();
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }

    public String[] getSecurityUser() {
        return securityUser;
    }

    public void setSecurityUser(String[] securityUser) {
        this.securityUser = securityUser;
    }
}
